
#include "i2c.h"
#include "Delay.h"

void AT24C02_Write(unsigned char dizhi,unsigned char time)
{
	IIC_Start();
	IIC_SendByte(0xa0);//
	IIC_WaitAck();
	
	IIC_SendByte(dizhi);
	IIC_WaitAck();
	
	IIC_SendByte(time);
	IIC_WaitAck();
	IIC_Stop();
	Delay(5);
}

unsigned char AT24C02_Read(unsigned char dizhi)
{
	unsigned char time;
	IIC_Start();
	IIC_SendByte(0xa0);//
	IIC_WaitAck();
	
	IIC_SendByte(dizhi);
	IIC_WaitAck();

	IIC_Start();
	IIC_SendByte(0xa1);//
	IIC_WaitAck();
	
	time = IIC_RecByte();
	IIC_SendAck(1);
	IIC_Stop();
	Delay(5);
	return time;
}